﻿using System;
using System.Windows.Data;
using WhiteFlow.DevTrackingTool.UI.Entities;

namespace WhiteFlow.DevTrackingTool.UI.Converters
{
    public class BackstageTabConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
                return -1;

            if (value is BackstageTab)
            {
                switch ((BackstageTab)value)
                {
                    case BackstageTab.Backstage: return -1;
                    case BackstageTab.Worksheet: return 0;
                    default: return -1;
                }
            }
            else return -1;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
                return BackstageTab.Backstage;

            switch ((int)value)
            {
                case 0:
                    return BackstageTab.Worksheet;
                case -1:
                default:
                    return BackstageTab.Backstage;
            }
        }
    }
}